<?php

namespace Jobeet\Bundle\Form\Type;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;

class JobType extends AbstractType
{
    public function buildForm(FormBuilder $builder, array $options)
    {        
        $builder->add('category', 'entity', array
                                            (
                                                'class' => 'Jobeet\Bundle\Entity\Category',
                                                'property' => 'name',
                                                'query_builder' => function ($repository) 
                                                                   { 
                                                                        return 
                                                                        $repository->createQueryBuilder('p')
                                                                        ->orderBy('p.name', 'ASC'); 
                                                                   },
                                                'label' => 'Category' 
                                            ));

        $builder->add('type' , 'text');
        $builder->add('company', 'text');
        $builder->add('logo', 'url');
        $builder->add('url', 'url');
        $builder->add('position', 'text');
        $builder->add('location', 'text');
        $builder->add('description', 'textarea');
        $builder->add('howToApply', 'text');
        $builder->add('token', 'text');
        $builder->add('isPublic', 'checkbox');
        $builder->add('isActivated', 'checkbox');
        $builder->add('email', 'email');
        //$builder->add('', 'category', array(
        //                              'choices' => $names
        //                                    ));
    }

    public function getDefaultOptions(array $options)
    {
        return array(
            'data_class' => 'Jobeet\Bundle\Entity\Job',
        );
    }
    
    public function getName()
    {
        return 'job';
    }
}
?>
